package top.starmc.starpet.entity;

import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityCreature;
import net.minecraft.server.v1_12_R1.PathfinderGoalRandomLookaround;
import net.minecraft.server.v1_12_R1.World;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.entity.Player;
import top.starmc.starpet.entity.ai.PetFollowOwner;
import top.starmc.starpet.internal.PlayerData;

public class EntityPet extends EntityCreature {
    public EntityPet(World world) {
        super(world);
        die();
    }

    public EntityPet(Player p, PlayerData data, Location loc) {
        super(((CraftWorld) loc.getWorld()).getHandle());
        goalSelector.a(0, new PetFollowOwner(this, p));
        goalSelector.a(1, new PathfinderGoalRandomLookaround(this));
        setPosition(loc.getX(), loc.getY(), loc.getZ());
        setCustomName(data.getLevelName());
        setCustomNameVisible(true);
        getWorld().addEntity(this);
    }

    @Override
    public boolean damageEntity(DamageSource source, float damage) {
        return false;
    }
}
